<template>
    <van-nav-bar title="搜索" left-text="返回" left-arrow @click-left="() => { $router.push('/home/index') }" />
    <van-search v-model="search" shape="round" placeholder="请输入搜索关键词" />
    <template v-if="search.length == 0 || searchdata.length === 0">
        <van-empty description="暂无数据" />
    </template>
    <template v-else>

        <van-cell-group v-for="item in searchdata">
            <router-link :to="'/xiangqing/'+item.goods_id">
                <van-cell :title="item.goods_name" />
            </router-link>
        </van-cell-group>

    </template>

</template>

<script setup>
import { ref, watch } from "vue";
import { searchApi } from '@/api/api'
const search = ref('')
import _ from 'loadsh'
let searchdata = ref([])
watch(search, (search) => {
    searchApi(search).then(res => {
        console.log('搜索数据', res);
        searchdata.value = res.data.message.goods
    })
})



</script>

<style lang="scss" scoped></style>